// pages/buyerbox/index/index.js
import {
  getUserOrder,
  buyertixingfahuo
} from '../../../utils/networkRequest.js'
import {
  errorMsg
} from '../../../utils/tool.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    curTab: 1,

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {



    let self = this;
    getUserOrder(this.data.curTab, (r) => {
      if (r.code == 0) {
        self.setData({
          dataSource: r.data,
          status: r.couts
        })
      } else {
        errorMsg(r.message)
      }
    })
  },
  goViewOrder: function(e) {
    let orderId = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../../myorderbox/vieworderdetail/vieworderdetail?orderId=' + orderId,
    })
  },
  changeState: function(e) {
    let self = this;
    let state = e.currentTarget.dataset.state;
    getUserOrder(state, (r) => {
      if (r.code == 0) {
        self.setData({
          dataSource: r.data,
          status: r.couts,
          curTab: state
        })
      } else {
        errorMsg(r.message)
      }
    })

  },
  gotoShangJia: function() {
    wx.reLaunch({
      url: '../../about/about?goto=shangjia',
    })
  },
  //提醒发货
  tixingfahuo: function(e) {
    let id = e.currentTarget.dataset.id;
    buyertixingfahuo(id, (r) => {
      if (r.code == 0) {
        errorMsg(r.message)
      } else {
        errorMsg(r.message)
      }

    })
  }
})